<?php
	$id=!empty($_GET["id"])?$_GET["id"]*1:NULL;
	$key=!empty($_GET["key"])?trim($_GET["key"]):NULL;
	$firstRow=!empty($_GET["firstRow"])?$_GET["firstRow"]:NULL;
	$totalRows=!empty($_GET["totalRows"])?$_GET["totalRows"]:NULL;
	$cat_id = !empty($_GET['cat_id']) ? $_GET['cat_id']*1 : '';
	//===================================分类
	if(!empty($key))
		$scl.=" and ( spot_name like '%$key%' )";
	if(!empty($cat_id))
		$scl.=" and cat_id = '$cat_id'";
	if($dpid)
		$scl.=" and province='".getdistrictid($dpid)."'";
	if($dcid)
		$scl.=" and city='".getdistrictid($dcid)."'";
	if($daid)
		$scl.=" and areaid='".getdistrictid($daid)."'";
	//--------------------------------------------------
	//=============================================所有分类=============================
	$csql = "select * from ".SPOTCAT." where statu = 1 ";
	$db->query($csql);
	$cat_list = $db->getRows();
	$tpl->assign('cat_list',$cat_list);


	include_once("includes/page_utf_class.php");
	$page = new Page;
	$page->url=$config['weburl'].'/';
	$page->listRows= 36;

	$sql="SELECT * FROM ".SPOT." where statu = 1 $scl order by id desc";
		
	if(!$page->__get('totalRows'))
	{
		$db->query($sql);
		$page->totalRows =$db->num_rows();
	}
	$sql.=" limit ".$page->firstRow.", ".$page->listRows;
	//--------------------------------------------------
	$db->query($sql);
	$prol=$db->getRows();

	$prolist['list']=$prol;
	$prolist['page']=$page->get_pc_prompt();
	$prolist['count']=$page->totalRows;

	foreach($prolist['list'] as $key=>$val){
		$db->query("select cat_name from ".SPOTCAT." where id = '{$val['cat_id']}' ");
		$spot_cat = $db->fetchRow();
		$prolist['list'][$key]['cat_name'] = $spot_cat['cat_name'];
	}
	$tpl->assign("info",$prolist);


	//------------------------------------------------------
	$url=implode('&',convert($_GET));
	$tpl->assign("url",$url);
	
	//----------------------------SEO
	$config['title']=str_replace('[catname]',$cat['cat'],$config['title2']);
	$config['keyword']=str_replace('[catname]',$cat['cat'],$config['keyword2']);
	$config['description']=str_replace('[catname]',$cat['cat'],$config['description2']);
	
	//=====================================================

	$tpl->assign("cat_id",$cat_id);
	include_once("footer.php");
	$out=tplfetch("spot_list.htm");
?>